package com.example.config;

import com.example.component.AuthHandlerInterceptor;
import jakarta.annotation.Resource;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class AuthWebMvcConfigurer implements WebMvcConfigurer {
    @Resource
    AuthHandlerInterceptor authHandlerInterceptor;

    /**
     * 给除了 /login 的接口都配置拦截器, 拦截转向到 authHandlerInterceptor
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(authHandlerInterceptor)
                .addPathPatterns("/**")
                .excludePathPatterns("/api/login","/api/wechatLogin","/api/register","/api/send","/api/email_login","/api/market/selectMarketHot","/api/item/selectItemAll","/api/retail/selectPostDescByUid","/api/retail/selectPostItemByUid","/api/retail/selectPostCommentByUid","/api/retail/selectPostAll","/api/qr/generate-code","/files/uploadPost","/files/upload","/files/uploadWechat");
    }
}
